<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script>
		function isPrime(num) {
			// 小于三的只有2，3两个质数
			if (num <= 3) {
				return num > 1;
			}
			// 不在6的倍数两侧，都为假
			if (num % 6 !== 1 && num % 6 !== 5) {
				return false;
			}
			let sqrt = Math.sqrt(num);
			for (let i = 5; i < sqrt; i += 6) {
				if (num % i === 0 || num % (i + 2) === 0) {
					return false;
				}
			}
			return true;
		}
		let num = 7;
		console.log(isPrime(num));
	</script>
	
</body>
</html>